package com.stoa.floatlib.utils

import com.tencent.mmkv.MMKV

object SpUtils {
    private val defaultMMKV: MMKV = MMKV.defaultMMKV()

    fun contains(key: String): Boolean = defaultMMKV.contains(key)

    fun remove(key: String) = defaultMMKV.remove(key)

    fun putBoolean(key: String, value: Boolean) = defaultMMKV.putBoolean(key, value)

    fun getBoolean(key: String, def: Boolean = false): Boolean = defaultMMKV.getBoolean(key, def)

    fun putBytes(key: String, value: ByteArray) = defaultMMKV.putBytes(key, value)

    fun getBytes(key: String, def: ByteArray? = null) = defaultMMKV.getBytes(key, def)

    fun putInt(key: String, value: Int) = defaultMMKV.putInt(key, value)

    fun getInt(key: String, def: Int = 0): Int = defaultMMKV.getInt(key, def)

    fun putFloat(key: String, value: Float) = defaultMMKV.putFloat(key, value)

    fun getFloat(key: String, def: Float = 0f): Float = defaultMMKV.getFloat(key, def)

    fun putLong(key: String, value: Long) = defaultMMKV.putLong(key, value)

    fun getLong(key: String, def: Long = 0): Long = defaultMMKV.getLong(key, def)

    fun putString(key: String, value: String) = defaultMMKV.putString(key, value)

    fun getString(key: String, def: String = ""): String? = defaultMMKV.getString(key, def)

    fun putStringSet(key: String, set: MutableSet<String>) = defaultMMKV.putStringSet(key, set)

    fun getStringSet(key: String, def: MutableSet<String>? = null): MutableSet<String>? =
        defaultMMKV.getStringSet(key, def)
}